﻿using System;
using System.Collections.Generic;
using System.Linq;
using UcAsp.Net.Model;
namespace UcAsp.Net.NOSQLDAL
{
    public class SetFiledDAL : UcAsp.Net.IDAL.ISetFiledDAL
    {
        public List<SetFiled> GetSetFiled()
        {
            return STSData.GetInstance.Select<Model.SetFiled>();
        }
        public List<SetFiled> Select(int categoriesid)
        {
            var query = GetSetFiled().Where(o => o.CategoreiesID == categoriesid).OrderBy(o=>o.Rank);
            return query.ToList();
        }
        public SetFiled Limit(int id)
        {
            return GetSetFiled().FirstOrDefault(o => o.FiledID == id);
        }
        public bool Insert(SetFiled model)
        {
            long key;
            Model.SetFiled lastrow = STSData.GetInstance.LastRow<Model.SetFiled>(out key);
            model.FiledID = Convert.ToInt32(key.ToString()) + 1;
            STSData.GetInstance.Insert<Model.SetFiled>(model.FiledID, model);
            return true;
        }
        public bool Update(SetFiled model)
        {
            STSData.GetInstance.Update<Model.SetFiled>(model.FiledID, model);
            return true;
        }
        public bool Delete(SetFiled model)
        {
            STSData.GetInstance.Delete<Model.SetFiled>(model.FiledID);
            return true;
        }
    }
}